#include "DocXmlHandler.h"
#include <list>
#include "BlockXmlHandler.h"

namespace xpm {
	void DocXmlHandler::Parse() {
		DOMElement* xmlRoot = _doc->getDocumentElement();
		DOMNamedNodeMap* map = xmlRoot->getAttributes();
		DOMNode* node = NULL;
	}

	void DocXmlHandler::Serialize() {		
		DOMElement* xmlRoot = _doc->getDocumentElement();
		DOMNamedNodeMap* map = xmlRoot->getAttributes();
		DOMNode* node = NULL;
		//to do: parse the attributes
		
		std::list<XpmTermBlock*> blocks = _xpmdoc->GetTermBlocks();
		DOMElement* nodeElement = NULL;
		XMLCh* blockName = XMLString::transcode("Block");
		for(std::list<XpmTermBlock*>::iterator it = blocks.begin(); it != blocks.end(); ++it) {
			nodeElement = _doc->createElement(blockName);
			xmlRoot->appendChild(nodeElement);
			BlockXmlHandler blockHandler(_doc, nodeElement, *it);
			blockHandler.Serialize();
		}
		XMLString::release(&blockName);
	}
}